home *** CD-ROM | disk | FTP | other *** search
/ 15 Beaut Aussie Games 1 / BEAUTGAMESV1.iso / pc / Windows / data1.cab / Program_Files / dswmedia / games / canetoad.dcr / gameControl_1_gameControl parent.ls < prev    next >
Encoding:
Text File  |  2002-01-01  |  4.4 KB  |  168 lines

  1. property score, time, daySprite, dayType, damage, sDamage, action, Distance, levelNum, maxtoad1, maxtoad2, maxtoad3
  2. global level
  3.  
  4. on new me
  5.   time = 0
  6.   score = 0
  7.   sDamage = 28
  8.   action = "play"
  9.   levelNum = 1
  10.   level = levelNum
  11.   Distance = 0
  12.   puppetSprite(sDamage, 1)
  13.   damage = 0
  14.   put "0" into field "toad1score"
  15.   put "0" into field "toad2score"
  16.   put "0" into field "toad3score"
  17.   calcDamage(me, 0)
  18.   return me
  19. end
  20.  
  21. on updateGame me
  22.   global background, hero, obstacles, hit, projector
  23.   if projector then
  24.     move(background)
  25.   end if
  26.   move(hero)
  27.   repeat with i = 1 to count(obstacles)
  28.     move(getAt(obstacles, i))
  29.   end repeat
  30.   set the loc of sprite hit to point(-100, -100)
  31.   checkCollision(me)
  32.   Distance = Distance + 1
  33.   if Distance > (1500 + (500 * levelNum)) then
  34.     action = "levelDone"
  35.     endLevel(hero)
  36.   end if
  37. end
  38.  
  39. on checkCollision me
  40.   global hero, obstacles
  41.   repeat with i = 1 to count(obstacles)
  42.     if (the locV of sprite hero.sNumber > the locV of sprite getAt(obstacles, i).sNumber) and (getAt(obstacles, i).action = "alive") then
  43.       if sprite hero.sNumber intersects getAt(obstacles, i).sNumber and (abs(the locH of sprite hero.sNumber - the locH of sprite getAt(obstacles, i).sNumber) < 25) then
  44.         hit(getAt(obstacles, i))
  45.         exit repeat
  46.       end if
  47.     end if
  48.   end repeat
  49. end
  50.  
  51. on calcDamage me, howMuch
  52.   global damage, sDamage, hero
  53.   damage = damage + howMuch
  54.   set the rect of sprite sDamage to rect(35, 75 - damage, 67, 75)
  55.   if damage >= 71 then
  56.     damage = 71
  57.     set the rect of sprite sDamage to rect(35, 4, 67, 75)
  58.     if hero.action <> "dead" then
  59.       die(hero)
  60.     end if
  61.   end if
  62.   if damage <= 0 then
  63.     damage = 0
  64.     set the rect of sprite sDamage to rect(35, 75, 67, 75)
  65.   end if
  66. end
  67.  
  68. on turnOff me
  69.   repeat with i = 1 to count(obstacles)
  70.     turnOff(getAt(obstacles, i))
  71.   end repeat
  72. end
  73.  
  74. on initLevel me
  75.   levelNum = levelNum + 1
  76.   level = levelNum
  77.   Distance = 0
  78.   action = "play"
  79. end
  80.  
  81. on moveToFinished me
  82.   global background, hero, obstacles, hit
  83.   if background.vIncr > 0 then
  84.     background.vIncr = background.vIncr - 0.5
  85.   end if
  86.   repeat with i = 1 to count(obstacles)
  87.     getAt(obstacles, i).vIncr = background.vIncr
  88.     move(getAt(obstacles, i))
  89.   end repeat
  90.   move(background)
  91.   moveToFinished(hero)
  92.   set the loc of sprite hit to point(-100, -100)
  93. end
  94.  
  95. on calcScore me, whichToad
  96.   case whichToad of
  97.     1:
  98.       put value(field("toad1score")) + 1 into field "toad1score"
  99.     2:
  100.       put value(field("toad2score")) + 1 into field "toad2score"
  101.     3:
  102.       put value(field("toad3score")) + 1 into field "toad3score"
  103.   end case
  104. end
  105.  
  106. on startRepairs me
  107.   turnOff(me)
  108.   maxtoad1 = value(field("toad1score"))
  109.   maxtoad2 = value(field("toad2score"))
  110.   maxtoad3 = value(field("toad3score"))
  111.   repeat with i = 1 to 48
  112.     set the visible of sprite i to 1
  113.   end repeat
  114. end
  115.  
  116. on moreRepairs me
  117.   if value(field("toad3score")) <= 0 then
  118.     if value(field("toad2score")) <= 0 then
  119.       if value(field("toad1score")) <= 0 then
  120.       else
  121.         put value(field("toad1score")) - 1 into field "toad1score"
  122.         calcDamage(me, -0.25)
  123.       end if
  124.     else
  125.       put value(field("toad2score")) - 1 into field "toad2score"
  126.       calcDamage(me, -0.5)
  127.     end if
  128.   else
  129.     put value(field("toad3score")) - 1 into field "toad3score"
  130.     calcDamage(me, -1)
  131.   end if
  132. end
  133.  
  134. on lessRepairs me
  135.   if value(field("toad1score")) >= maxtoad1 then
  136.     if value(field("toad2score")) >= maxtoad2 then
  137.       if value(field("toad3score")) >= maxtoad3 then
  138.       else
  139.         put value(field("toad3score")) + 1 into field "toad3score"
  140.         calcDamage(me, 1)
  141.       end if
  142.     else
  143.       put value(field("toad2score")) + 1 into field "toad2score"
  144.       calcDamage(me, 0.5)
  145.     end if
  146.   else
  147.     put value(field("toad1score")) + 1 into field "toad1score"
  148.     calcDamage(me, 0.25)
  149.   end if
  150. end
  151.  
  152. on repair me
  153.   if ((value(field("toad1score")) = maxtoad1) and (value(field("toad2score")) = maxtoad2) and (value(field("toad3score")) = maxtoad3)) or (damage >= 71) then
  154.     set the visible of sprite 41 to 0
  155.     set the visible of sprite 43 to 0
  156.   else
  157.     set the visible of sprite 41 to 1
  158.     set the visible of sprite 43 to 1
  159.   end if
  160.   if ((value(field("toad1score")) = 0) and (value(field("toad2score")) = 0) and (value(field("toad3score")) = 0)) or (damage <= 0) then
  161.     set the visible of sprite 40 to 0
  162.     set the visible of sprite 42 to 0
  163.   else
  164.     set the visible of sprite 40 to 1
  165.     set the visible of sprite 42 to 1
  166.   end if
  167. end
  168.